﻿<UserControl x:Class="OneTo50.UserControls.CountryScoreList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:uc="clr-namespace:OneTo50.UserControls"
    mc:Ignorable="d"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480" Loaded="UserControl_Loaded_1">

    <Grid x:Name="LayoutRoot">
        <Grid x:Name="gdCountryScore">
            <Grid.RowDefinitions>
                <RowDefinition Height="50" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="50" />
                    <ColumnDefinition Width="160" />
                    <ColumnDefinition Width="130" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <TextBlock Text="No" Style="{StaticResource ListHeaderText}" />
                <TextBlock Grid.Column="1" Text="Country" Style="{StaticResource ListHeaderText}" />
                <TextBlock Grid.Column="2" Text="score" Style="{StaticResource ListHeaderText}" />
                <TextBlock Grid.Column="3" Text="level" Style="{StaticResource ListHeaderText}" />
            </Grid>
            <ListBox Grid.Row="1" x:Name="lbWorldScores" ItemsSource="{Binding Items, Source={StaticResource CountryScoreViewModel}}">
                <ListBox.ItemContainerStyle>
                    <Style TargetType="ListBoxItem">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                    </Style>
                </ListBox.ItemContainerStyle>
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Border BorderThickness="0,0,0,1">
                            <Border.BorderBrush>
                                <LinearGradientBrush>
                                    <GradientStop Color="#00007900" Offset="0"></GradientStop>
                                    <GradientStop Color="#007900" Offset="0.35"></GradientStop>
                                    <GradientStop Color="White" Offset="0.5"></GradientStop>
                                    <GradientStop Color="#007900" Offset="0.55"></GradientStop>
                                    <GradientStop Color="#00007900" Offset="1"></GradientStop>
                                </LinearGradientBrush>
                            </Border.BorderBrush>
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition Height="50" />
                                    <RowDefinition Height="*" />
                                </Grid.RowDefinitions>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="50" />
                                    <ColumnDefinition Width="160" />
                                    <ColumnDefinition Width="130" />
                                    <ColumnDefinition Width="*" />
                                </Grid.ColumnDefinitions>
                                <TextBlock Grid.Column="0" Text="{Binding SortOrder}" Style="{StaticResource ListItemText}" />
                                <StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Center">
                                    <TextBlock Width="65" Text="{Binding CountryCode}" Style="{StaticResource ListItemText}" VerticalAlignment="Center" />
                                    <Image Source="{Binding CountryCode, Converter={StaticResource FlagImageSourceConverter}}" VerticalAlignment="Center" Width="16" Height="11" />
                                </StackPanel>
                                <TextBlock Grid.Column="2" Foreground="White" Text="{Binding Score, Converter={StaticResource ScoreFormatConverter}}" Style="{StaticResource ListItemText}" />
                                <uc:StarsRating HorizontalAlignment="Center" Grid.Column="3" Stars="{Binding Score, Converter={StaticResource StarLevelConverter}}" />
                            </Grid>
                        </Border>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
        </Grid>
        <Grid x:Name="gdError" Margin="10" VerticalAlignment="Top" Visibility="Collapsed">
            <TextBlock Style="{StaticResource ListHeaderText}" Foreground="#C3C3C3" Text="Sorry, can not get the scores for now. Please make sure you have connected to the internet and try again." TextWrapping="Wrap" FontSize="30" ></TextBlock>
        </Grid>
        <toolkit:PerformanceProgressBar VerticalAlignment="Bottom" IsIndeterminate="True" Visibility="Collapsed" x:Name="ppb"  />
    </Grid>
</UserControl>